home *** CD-ROM | disk | FTP | other *** search
- (*
- Degasgen, Translate .RLE file into a Degas .PI1 file
-
- FUNCTION:
-
- Degasgen takes a CompuServe Run Length Encoded (.RLE) format
- file and translates it into a DEGAS low resolution (.PI1)
- file suitable for editing with DEGAS.
-
- USAGE:
-
- The program is a .TOS file; it will prompt you for the names
- of two files: an RLE file and then a .PI1 file. If the .PI1
- file already exists, it will be overwritten.
-
- NOTES:
-
- RLE format files have a resolution of 256 wide by 192 deep.
- DEGAS .PI1 files have a resolution of 320 wide by 200 deep. Not
- only that, but they have 16 levels of color per pixel, whereas
- RLE files are strictly black or white. Thus, you may assume that
- RLE files do not tax the abilities of DEGAS. On the other hand,
- you can view RLE files on Commodore 64s, Atari 800s, Apples,
- etc.
-
- AUTHOR:
-
- Charles McGuinness, May 1986
-
- MODIFICATIONS:
-
- V1.1 May 27, 1986 Charles McGuinness
-
- o If file ends before ESC G H, don't cause run time error
- o End program with a PRESS RETURN TO CONTINUE
-
- <your name goes here ... don't forget to describe what you did>
-
- *)
-
- program degasgen;
-
- type timage = array [0..15999] of integer;
-
- tinf = packed file of byte;
-
- var image : ^timage; (* The Degas Image *)
-
- inf : tinf; (* What we read *)
- outf : file of integer; (* What we write *)
-
- line : string; (* Throw away string *)
-
- i : integer;
-
- c : byte;
-
- currow, curcol, black, white, white2 : integer;
-
- sdot : integer;
-
- (* The following two functions are defined by the Personal Pascal *)
- (* Compiler. *)
-
- procedure io_check(b:boolean); external;
- function io_result: integer; external;
-
- (* SET_PIX: *)
- (* *)
- (* Sets the specified pixel in the DEGAS image to either black *)
- (* or white (b=0 means black, b=1 means white). *)
- (* *)
- (* Note that in low resolution mode, each pixel on the ST's *)
- (* screen is represented by four bits in the screen. That's *)
- (* why we go through the fun of all this bit magic. *)
- (* *)
- (* Trust me, it works. *)
-
- procedure set_pix(x,y,b : integer);
- var normal, offset,u : integer;
- begin
-
- offset := (y * 80) + ((x div 16)*4);
-
- normal := 15 - (x & 15);
- u := shl(b,normal);
-
- image^[offset+0] := image^[offset+0] | u;
- image^[offset+1] := image^[offset+1] | u;
- image^[offset+2] := image^[offset+2] | u;
- image^[offset+3] := image^[offset+3] | u;
- end;
-
- (* How to exit the program from any point, and do it *)
- (* so that the user has a chance to see what's gone on *)
- procedure my_halt;
- begin
- write('Press RETURN to continue: ');
- readln;
- halt;
- end;
-
- procedure inc_sdot;
- begin
- sdot := sdot + 1;
-
- if ((sdot mod 64) = 0) then begin
- writeln;
- write('<',sdot:5,'>');
- end;
-
- write('.');
- end;
-
- function fgetc(var f : tinf): integer;
- var t : integer;
- begin
- io_check(FALSE); (* Turn off error checking *)
- get(f);
- if (0 <> io_result) then fgetc := -1
- else fgetc := (f^) & 127;
- io_check(TRUE);
- end;
-
- begin (* MAIN *)
-
- writeln('Degas to RLE Conversion program, version 1.1 (May 27, 1986)');
- writeln;
- writeln('Copyright (C) 1986, Charles McGuinness');
- writeln;
- writeln('Portions of this product are Copyright (c) 1986, OSS and CCD.');
- writeln('Used by Permission of OSS.'); (* Yes, this is personal pascal *)
- writeln;
-
- new(image);
-
- for i:=0 to 15999 do begin
- image^[i] := 0; (* Set the image to BLACK *)
- end;
-
- (* Open the input, output files.... *)
-
- write('Input (.RLE) file: ');
- readln(line);
-
- IO_Check(FALSE);
-
- reset(inf,line);
-
- i := io_result;
-
- if (i <> 0) then begin
- writeln('I was unable to open ',line);
- my_halt;
- end;
-
- io_check(TRUE);
- write('Output (.PI1) file: ');
- readln(line);
- io_check(FALSE);
- rewrite(outf,line);
- i := io_result;
- io_check(TRUE);
-
- if (i <> 0) then begin
- close(inf);
- writeln('I was unable to create ',line);
- my_halt;
- end;
-
- writeln;
- writeln('Reading input file ...');
-
- repeat
- c := inf^;
- get(inf);
- until (c & 127 = 27); (* Search for escape *)
-
- get(inf); (* Eat the G, leave the H in buffer *)
-
- curcol := 0;
- currow := 0;
- sdot := 0;
-
- writeln;
- write('< 0>.');
-
- repeat
-
- black := fgetc(inf)-32;
-
- if (black >= 0) then
- white := fgetc(inf)-32;
-
- if ((black >= 0) and (white >= 0)) then begin
- curcol := curcol + black;
-
- if (curcol >= 256) then begin
- inc_sdot;
- curcol := curcol - 256;
- currow := currow + 1;
- end;
-
- repeat
- white2 := 0;
- if ((curcol+white) >= 256) then begin
- inc_sdot;
- white2 := white+curcol - 256;
- white := 256 - curcol;
- end;
- if (white <> 0) then
- for i:= curcol to curcol+white-1 do
- set_pix(i,currow,1);
- curcol := curcol + white;
- if curcol = 256 then begin
- curcol := 0;
- currow := currow + 1;
- end;
- white := white2;
- until (white = 0);
- end;
- until ((white < 0) or (black < 0));
-
- writeln;
- writeln;
- writeln('Generating output file now ....');
-
- outf^ := 0;
- put(outf);
-
- for i :=0 to 15 do begin
- outf^ := (i div 2) * $111;
- put(outf);
- end;
-
- sdot := 0;
-
- for i := 0 to 15999 do begin
- if ((sdot mod (80*64)) = 0) then begin
- writeln;
- write('<',(sdot div 80):5,'>');
- end;
- if ((sdot mod 80) = 0) then
- write('.');
- sdot := sdot + 1;
- outf^ := image^[i];
- put(outf);
- end;
-
- close(outf);
- close(inf);
- writeln;
- writeln;
- writeln('Conversion Finished.');
- writeln;
- my_halt;
- end.
- əəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəə